<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
    <script src="js/axios-0.18.0.js"></script>
</head>
<body>
    <div id="app">

        <button @click="send">查询用户信息</button>

        <br>
        {{msg}}
    </div>

</body>

<script>
    new Vue({
        el:"#app",
        data:{
            msg:""
        },
        methods:{
            send(){
                axios.defaults.withCredentials = true;
                //路径必须写完整的url
                axios.get("http://localhost:81/user/findAll")
                .then(resp=>{
                   let r = resp.data;
                   if (r.code == 2000){
                       //未登录
                       location.href = "login.html";
                   }else if(r.code == 5000){
                       //没有访问权限
                       location.href = "auth.html";
                   }else{
                       //访问成功
                       this.msg = r.data;
                   }
                });
            }
        }
    });
</script>

</html>